#include<iostream>
#include<vector>

using namespace std;
    
int search(vector<int>& nums, int target) 
{
    int left = 0, right = nums.size() - 1;
        while(left <= right)
        {
            int i = (right - left) / 2 + left;
            if(nums[i] > target)
            {
                right = i-1;
            }
            else if(nums[i] < target)
            {
                left = i+1;
            }
            else 
                return i;
        }
        return -1;
}

int main()
{
   vector<int> v1;
   for(int i = 0; i < 10; i++)
	{
		v1.push_back(i);
	}
	cout << search(v1, 5) << endl;
	return 0;
}
